package com.xunwulian.dubbo.service;

import com.xunwulian.base.constant.ConstantBean;
import com.xunwulian.base.entity.CardInfoEntity;
import com.xunwulian.base.entity.User;
import org.apache.http.util.Asserts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


public class CardFileTask implements Runnable {
    private static final Logger logger = LoggerFactory.getLogger(CardFileTask.class);

    // 卡信息服务
    private InnerCardInfoService innerCardInfoService;

    // 卡文件导出的卡信息集合
    private List<CardInfoEntity> list;

    private Integer start;

    private Integer end;

    private String appID;

    private User user;

    public CardFileTask(InnerCardInfoService innerCardInfoService,
                        List<CardInfoEntity> list,
                        int start,
                        int end,
                        String appId,
                        User user) {

        Asserts.notNull(list, "list can not be null");

        this.innerCardInfoService = innerCardInfoService;
        this.list = list;
        this.start = start;
        this.end = end > list.size() ? list.size() : end;

        this.appID = appId;
        this.user = user;
    }

    /**
     * 单个线程实现rollback
     */
    @Override
    @Transactional
    public void run() {
        long timeA = System.currentTimeMillis();

        logger.error("" + (System.currentTimeMillis() - timeA) / 1000);
    }
}
